<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const persons = [
        {
          id: 1001,
          name: '周丹文',
          age: 25,
          address: '江西临川'
        },
        {
          id: 1002,
          name: '李泽锋',
          age: 22,
          address: '湖北黄冈'
        },
        {
          id: 1003,
          name: '罗智强',
          age: 19,
          address: '陕西西安'
        },
        {
          id: 1004,
          name: '张志华',
          age: 19,
          address: '广东河源'
        },
        {
          id: 1005,
          name: '程思双',
          age: 28,
          address: '湖北黄冈'
        }
      ]

      // forEach
      //   persons.forEach((item, index) => {
      //     console.log(item, index)
      //   })

      // map，一般都只会取某些属性
      //   const names = persons.map(item => item.name)
      //   console.log(names)

      // filter，所有的属性都保留，但是数组的个数，会根据条件来决定
      //   const newPersons = persons.filter(item => item.age < 22)
      //   console.log(newPersons)

      const addresses = [
        '江西临川',
        '湖北黄冈',
        '陕西西安',
        '广东河源',
        '湖北黄冈'
      ]
      const isInclude = addresses.includes('江西临川')
      console.log(isInclude)
    </script>
  </body>
</html>
